/**
 * Author: Brent Myers
 * Time-stamp: <2008-07-23 12:49:29 bam>
 * 
 * Simple Hash Functions
 * 
 */

#ifndef _SIMPLE_HASH_H_
#define _SIMPLE_HASH_H_

namespace genhash
{


/**
 * fail on compile for undefined key types
 */
template <class T>
struct IdentityHash
{
};

template <>
struct IdentityHash<int>
{	
	size_t operator()(const int& x, size_t size)
	{
		return size_t(x) % size;
	}
};

template <>
struct IdentityHash<float>
{
	size_t operator()(const float& x, size_t size)
	{
		return size_t(x) % size;
	}
};

template <class Config_>
struct SimpleHash
{
	typedef Config_ Config;
	typedef typename Config::KeyType key_type;

	size_t operator()(const key_type& k)
	{
		IdentityHash<key_type> hasher;
		return hasher(k, Config::max_size);
	}
};


}
#endif // _SIMPLE_HASH_H_

